<?php 
namespace Home\Model;
use Think\Model;
class CategoryModel extends Model {
	public function getCate(){
		$cate=$this->select();
	
		$tempArr=[];
		foreach ($cate as  $row) {
			if($row['fid']==0){
				$tempArr[]=$row; //把顶级的类放到这个空的数组里面
			}
		}

		foreach ($tempArr as $k => $father) {  //循环这个顶级分类的数组
			foreach ($cate as  $v) {      //循环我们取出来的那个数组$cate 
				if($v['fid']==$father['id']){  //如果这个值的[fid]与顶级father的id相等
					$tempArr[$k]['son'][]=$v;
				}
			}
		
			
		}
		
		return $tempArr;
	}

}
?>